import {useState,useEffect} from 'react'
import {  Outlet, useNavigate } from 'react-router-dom'
import { createStorage } from '@/utils/Storage';
const Storage = createStorage({ storage: localStorage });

const FrontendAuth = () => {
  const navigation = useNavigate()

  const [auth,setAuth] = useState(false)

  useEffect(() => {

    if(Storage.get("token",null)){

      setAuth(true)
    } else {
      navigation("/")
    }

  },[])

  return auth?<Outlet/>:null
}
export default  FrontendAuth
